package com.ruoyi.lyy.controller;


import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.lyy.domain.vo.PageQueryVO;
import com.ruoyi.lyy.domain.vo.MerchantVO;
import com.ruoyi.lyy.service.IMerchantService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商户表 前端控制器
 * </p>
 *
 * @author YueYang
 * @since 2025-11-12
 */
@RestController
@RequestMapping("/merchant")
@RequiredArgsConstructor
public class MerchantController {

    private final IMerchantService merchantService;

    /**
     * 查询商户详情列表信息
     * 分页查询 默认查第一页 每页5条
     * 带有经纬度参数 用于统计距离
     * 经纬度默认北京天安门
     */
    @GetMapping("/list")
    public AjaxResult list(
            @RequestParam(required = false, defaultValue = "116.397428") Double longitude,
            @RequestParam(required = false, defaultValue = "39.90923") Double latitude,
            @RequestParam(defaultValue = "1", required = false) Integer pageNum,
            @RequestParam(defaultValue = "5", required = false) Integer pageSize) {

        //分页查询商户信息
        PageQueryVO<MerchantVO> pageList = merchantService.pageMerchant(longitude, latitude, pageNum, pageSize);

        return AjaxResult.success("查询成功", pageList);
    }


    /**
     * 根据商户id查询商户信息
     *
     * @param id 商户id
     * @return 返回查询结果
     */
    @GetMapping("/{id}")
    public AjaxResult getMerchantById(@PathVariable("id") Integer id) {
        return null;
    }


}
